package com.gitee.wsl.concurrent.service

import com.gitee.wsl.concurrent.Future
import kotlinx.coroutines.Delay
import kotlinx.coroutines.InternalCoroutinesApi

/**
 * A delayed result-bearing action that can be cancelled.
 * Usually a scheduled future is the result of scheduling
 * a task with a [ScheduledExecutorService].
 *
 * @since 1.5
 * @author Doug Lea
 * @param <V> The result type returned by this Future
</V> */
@OptIn(InternalCoroutinesApi::class)
interface ScheduledFuture<V> : Delay, Future<V>

//class ScheduledFutureImp<V>(
//
//):ScheduledFuture<V>{
//    override fun invokeOnTimeout(
//        timeMillis: Long,
//        block: Runnable,
//        context: CoroutineContext
//    ): DisposableHandle {
//        val task = TimedTask((currentTimeMillis + timeMillis).milliseconds, null, block)
//        synchronized(lock) { timedTasks += task }
//        return DisposableHandle { synchronized(lock) { timedTasks -= task } }
//    }
//
//    override fun scheduleResumeAfterDelay(
//        timeMillis: Long,
//        continuation: CancellableContinuation<Unit>
//    ) {
//        scheduleResumeAfterDelay(timeMillis.milliseconds, continuation)
//    }
//}